package com.zy.openchat.core.model.circle;
import com.zy.openchat.core.model.message.TextEntity;
import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.List;

public class TextEntities implements Parcelable {
    @SerializedName(value = "@type")
    public String type = "entities";
    public List<TextEntity> entities;

    public TextEntities(List<TextEntity> entities) {
        this.entities = entities;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.type);
        dest.writeList(this.entities);
    }

    public void readFromParcel(Parcel source) {
        this.type = source.readString();
        this.entities = new ArrayList<TextEntity>();
        source.readList(this.entities, TextEntity.class.getClassLoader());
    }

    public TextEntities() {
    }

    protected TextEntities(Parcel in) {
        this.type = in.readString();
        this.entities = new ArrayList<TextEntity>();
        in.readList(this.entities, TextEntity.class.getClassLoader());
    }

    public static final Parcelable.Creator<TextEntities> CREATOR = new Parcelable.Creator<TextEntities>() {
        @Override
        public TextEntities createFromParcel(Parcel source) {
            return new TextEntities(source);
        }

        @Override
        public TextEntities[] newArray(int size) {
            return new TextEntities[size];
        }
    };
}
